package com.tanhua.server.controller;

import com.tanhua.server.service.UserCountService;
import com.tanhua.server.vo.CountsVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("users")
public class UserCountController {
    @Autowired
    private UserCountService userCountService;

    /**
     * 获取互相喜欢,喜欢,粉丝的数量
     * @return
     */
    @GetMapping("counts")
    public ResponseEntity<CountsVo> getCountUsers() {
        CountsVo countsVo = null;
        try {
            countsVo = userCountService.getCountUsers();
            if (countsVo == null) {
                return ResponseEntity.ok(new CountsVo());
            }
        } catch (Exception e) {
            return ResponseEntity.ok(new CountsVo());
        }
        return ResponseEntity.ok(countsVo);
    }


}
